//
//  AttentionCell.swift
//  maosheng
//
//  Created by lxl on 2019/8/12.
//

import UIKit
import Kingfisher
class AttentionCell: UITableViewCell {
    let userImg = UIImageView()
    let titleLab = UILabel()
    let attentionBtn = UIButton(type: .custom)

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .white
        configCell()
        selectionStyle = .none

    }
    
    
    func configCell() -> Void {
        
        let bottomLineView = UIView()
        contentView.addSubview(bottomLineView)
        bottomLineView.backgroundColor = KYP_f2f2f2_COLOR
        bottomLineView.snp.makeConstraints { (make) in
            make.left.equalTo(0)
            make.right.bottom.equalTo(0)
            make.height.equalTo(5)
        }
        
        let imgHeight = 75
        userImg.layer.cornerRadius = CGFloat(imgHeight/2)
        userImg.layer.masksToBounds = true
        userImg.contentMode = .scaleAspectFit
        userImg.image = UIImage(named: "")
        contentView.addSubview(userImg)
        userImg.snp.makeConstraints { (make) in
            make.left.equalTo(15)
            make.width.height.equalTo(imgHeight)
            make.top.equalTo(10)
            make.bottom.equalTo(bottomLineView.snp.top)
        }
    
        contentView.addSubview(titleLab)
        titleLab.textAlignment = .left
        titleLab.textColor = KYP_333333_COLOR
        titleLab.font = UIFont(name: "PingFangSC-Regular", size: 13)
        titleLab.snp.makeConstraints { (make) in
            make.left.equalTo(userImg.snp.right).offset(15)
            make.top.bottom.equalTo(0)
        }
        
        
//        attentionBtn.addTarget(self, action: #selector(btnClick(btn:)), for: .touchUpInside)
//        attentionBtn.setTitleColor(Color_333333, for: .normal)
        attentionBtn.contentEdgeInsets = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12)
        attentionBtn.layer.cornerRadius = 15
        attentionBtn.layer.masksToBounds = true
        attentionBtn.backgroundColor = .gray
        attentionBtn.setTitleColor(.white, for: .normal)
        attentionBtn.setTitle("取消关注", for: .normal)
        attentionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
        contentView.addSubview(attentionBtn)
        attentionBtn.snp.makeConstraints { (make) in
            make.centerY.equalTo(contentView)
            make.right.equalTo(-15)
            make.height.equalTo(30)
        }
    
    }
 
    func setTheAttentionInfo(model : AttentinModel) -> Void {
        titleLab.text = model.nickName
        let avater = model.avatar != nil ? model.avatar : ""
        userImg.kf.setImage(with: URL(string: avater!), placeholder: UIImage(named: "login_head_moren"))
       
    }
}
